/**
 * 
 */
package com.gosophia.commons.persistence.test.unit;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.transaction.TransactionConfiguration;

import com.gosophia.commons.DateTranslate;
import com.gosophia.commons.OrderCondition;
import com.gosophia.commons.Page;
import com.gosophia.commons.PropertyFilter;
import com.gosophia.commons.PropertyFilter.OperatorType;
import com.gosophia.commons.persistence.HibernateRepository;
import com.gosophia.commons.persistence.test.organizationManagement.dao.UserInfoDao;
import com.gosophia.commons.persistence.test.organizationManagement.entity.UserInfo;
import com.gosophia.commons.persistence.test.organizationManagement.entity.Organization;

/**
    * 功能：测试新增的 or and 支持
    * 测试用例说明：
    * PropertyFilter的构造说明
    * 测试编号001    A and B and C   构造propertyFilter list 即可
    * 测试编号002     A or B or C      
    * 测试编号00 3    (A and B) or C
    * 测试编号00 4    A and (B or C)
    * 测试编号00 5    (A or B) and C
    * 测试编号00 6    (A and B) or (C and D)
    * 测试编号00 7    (A or B or C ) and (D or E)
    * 测试编号00 8   (A and B) or (C and D)  重名参数测试
 * 
 * @author zhangdongsheng
 * @since 2010-10-27 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@ContextConfiguration(locations = { "classpath:applicationContext-test.xml",
        "classpath:moduleContext.xml" })
@TransactionConfiguration(defaultRollback = true)
public class UTHibernateRepository extends
        AbstractTransactionalJUnit4SpringContextTests {

    @Autowired
    private UserInfoDao userInfoDao;
    private Page<UserInfo> page;
    private List<PropertyFilter> propertyFilters;
    
    @Autowired
    private HibernateRepository<Organization,Long> testDAO;
    
    @Before
    public void initTest(){
        page = new Page<UserInfo>();
        page.setPageNo(1);
        page.setPageSize(10);
        propertyFilters = new ArrayList<PropertyFilter>();
    }

     private void printPramValues(Map<String,Object> paramValues){
        Set<Entry<String,Object>> entries =  paramValues.entrySet();
        String outStr ="";
        int count=0;
        for (Entry<String, Object> entry : entries) {
            count++;
            outStr = outStr + "("+count +"key:["+entry.getKey()+"]"+"value:["+entry.getValue()+"]"+") | ";
        }
        System.out.println("输出参数值："+ outStr);
     }
    
     /*  
      * 测试模式： A  and B  and C
      * */
     @Test
     public void test_001() {
         System.out.println("[test001]----------------------"
                 + "  A  and B  and C--------------------------");
         
         PropertyFilter A = new PropertyFilter("userName", OperatorType.EQ, "马跃");
         PropertyFilter B = new PropertyFilter("userAddress", OperatorType.EQ, "吉林省");
         PropertyFilter C = new PropertyFilter("userEmail", OperatorType.EQ, "mayue@163.com");
         
         ArrayList<PropertyFilter> aAndFilters = new ArrayList<PropertyFilter>();
         aAndFilters.add(B);
         aAndFilters.add(C);
         A.and(aAndFilters);
        
         propertyFilters.add(A);
         //测试生成hql正确
         String actual = HibernateRepository.getNameHql2(A);
         String expected = "(_e.userName=:userName and (_e.userAddress=:userAddress and _e.userEmail=:userEmail))";
         System.out.println("test_002 expected hql==>" + expected);
         System.out.println("test_002 acturl hql==>" + actual);
//         Assert.assertEquals(expected, actual);
         //测试提取值正确
         Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
         printPramValues(paramValues);
         Assert.assertEquals(3, paramValues.size());
         
         
         //测试集成
         Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                 propertyFilters);
         
         Assert.assertEquals(1, resultPage.getTotalCount());
     }
     
     /*  
      * 测试模式： A  and B  and C
      * */
     @Test
     public void test_001_() {
       
         
         PropertyFilter A = new PropertyFilter("userName", OperatorType.EQ, "马跃");
         PropertyFilter B = new PropertyFilter("userAddress", OperatorType.EQ, "吉林省");
         PropertyFilter C = new PropertyFilter("userEmail", OperatorType.EQ, "mayue@163.com");
        
        
         propertyFilters.add(A);
         propertyFilters.add(B);
         propertyFilters.add(C);
         //测试生成hql正确
         String actual = HibernateRepository.changePropertyFiltersToNameHql(A,B,C);
         String expected = "_e where (_e.userName=:userName) and (_e.userAddress=:userAddress) and (_e.userEmail=:userEmail)";
         System.out.println("test_002 expected hql==>" + expected);
         System.out.println("test_002 acturl hql==>" + actual);
//         Assert.assertEquals(expected, actual.trim());
         //测试提取值正确
         Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A,B,C);
         printPramValues(paramValues);
         Assert.assertEquals(3, paramValues.size());
         
         
         //测试集成
         Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                 propertyFilters);
         
         Assert.assertEquals(1, resultPage.getTotalCount());
     }

    /* 测试propertyFilter 转化成 hql
     * 测试模式： A  or B  or C
     * */
    @Test
    public void test_002() {
        System.out.println("[test002]----------------------"
                + " A  or B  or C--------------------------");
        
        PropertyFilter A = new PropertyFilter("userName", OperatorType.EQ, "马跃");
        PropertyFilter B = new PropertyFilter("userName", OperatorType.EQ, "王新兵");
        PropertyFilter C = new PropertyFilter("userName", OperatorType.EQ, "张三");
        
        ArrayList<PropertyFilter> aOrFilters = new ArrayList<PropertyFilter>();
        aOrFilters.add(B);
        aOrFilters.add(C);
        A.or(aOrFilters);
       
        propertyFilters.add(A);
        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        String expected = "(_e.userName=:userName or _e.userName=:userName_1 or _e.userName=:userName_1_1)";
        System.out.println("test_002 expected hql==>" + expected);
        System.out.println("test_002 acturl hql==>" + actual);
//        Assert.assertEquals(expected, actual);
        //测试提取值正确
        Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
        printPramValues(paramValues);
        Assert.assertEquals(3, paramValues.size());
        
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        
        Assert.assertTrue(resultPage.getTotalCount() > 0);
    }
    
    /**
     * 当propertyFilter需要或处理时（or），测试输出语句是否是合乎规格的hql 
     * 测试模式： (a and b) or c
     * 
     * */
    @Test
    public void test_003() {

        System.out.println("[test003]----------------------"
                + " (a and b) or c--------------------------");
        PropertyFilter A = new PropertyFilter("userName", OperatorType.EQ, "王新兵");
        PropertyFilter B = new PropertyFilter("userAddress", OperatorType.EQ, "河北省");
        PropertyFilter C = new PropertyFilter("userName", OperatorType.EQ, "张三");
        
        ArrayList<PropertyFilter> aAndFilters = new ArrayList<PropertyFilter>();
        ArrayList<PropertyFilter> aOrFilters = new ArrayList<PropertyFilter>();
        aAndFilters.add(B);
        aOrFilters.add(C);
        A.and(aAndFilters);
        A.or(aOrFilters);
       
        propertyFilters.add(A);
        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        String expected = "(_e.userName=:userName and (_e.userAddress=:userAddress) or _e.userName=:userName_1)";
        System.out.println("test_002 expected hql==>" + expected);
        System.out.println("test_002 acturl hql==>" + actual);
//        Assert.assertEquals(expected, actual);
        //测试提取值正确
        Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
        printPramValues(paramValues);
        Assert.assertEquals(3, paramValues.size());
        
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        
        Assert.assertEquals(2, resultPage.getTotalCount());
    }
    
    /**
     * 当propertyFilter需要或处理时（or），测试输出语句是否是合乎规格的hql 
     * 测试模式： a and (b or c)
     * 
     * */
    @Test
    public void test_004() {

        System.out.println("[test004]----------------------"
                + "A and (B or C)--------------------------");
        PropertyFilter A = new PropertyFilter("userBirthday", OperatorType.EQ, DateTranslate.simpleStringToDate("2010-9-25"));
        PropertyFilter B = new PropertyFilter("userAddress", OperatorType.EQ, "河北省");
        PropertyFilter C = new PropertyFilter("userAddress", OperatorType.EQ, "河南");
        
        ArrayList<PropertyFilter> aAndFilters = new ArrayList<PropertyFilter>();
        ArrayList<PropertyFilter> bOrFilters = new ArrayList<PropertyFilter>();
        aAndFilters.add(B);
        bOrFilters.add(C);
        A.and(aAndFilters);
        B.or(bOrFilters);
       
        propertyFilters.add(A);
        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        String expected = "(_e.userBirthday=:userBirthday and (_e.userAddress=:userAddress or _e.userAddress=:userAddress_1))";
        System.out.println("test_002 expected hql==>" + expected);
        System.out.println("test_002 acturl hql==>" + actual);
//        Assert.assertEquals(expected, actual);
        //测试提取值正确
        Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
        printPramValues(paramValues);
        Assert.assertEquals(3, paramValues.size());
        
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        
        Assert.assertEquals(2, resultPage.getTotalCount());
    }
    

 
    /**
     * 当propertyFilter需要或处理时（or），测试输出语句是否是合乎规格的hql 
     * 测试模式： a or (b and c)
     * 
     * */
    @Test
    public void test_005() {

        System.out.println("[test005]----------------------"
                + "A or (B and C)--------------------------");
       
        PropertyFilter A = new PropertyFilter("userName", OperatorType.EQ, "王新兵");
        PropertyFilter B = new PropertyFilter("userName", OperatorType.EQ, "张三");
        PropertyFilter C = new PropertyFilter("userAddress", OperatorType.EQ, "河南");
        
      
        //B and C
        ArrayList<PropertyFilter> bAndFilters = new ArrayList<PropertyFilter>();
        bAndFilters.add(C);
        B.and(bAndFilters);
        
        //A or B
        ArrayList<PropertyFilter> aOrFilters = new ArrayList<PropertyFilter>();
        aOrFilters.add(B);
        A.or(aOrFilters);
        
        propertyFilters.add(A);
        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        String expected = "(_e.userName=:userName or _e.userName=:userName_1 and (_e.userAddress=:userAddress))";
        System.out.println("test_002 expected hql==>" + expected);
        System.out.println("test_002 acturl hql==>" + actual);
//        Assert.assertEquals(expected, actual);
        //测试提取值正确
        Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
        printPramValues(paramValues);
        Assert.assertEquals(3, paramValues.size());
        
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        
        Assert.assertTrue(resultPage.getTotalCount() > 0);
    }
    
    /*
     * 测试对and的支持
     * 测试模式 （A and B）or (C and D )
     */
    @Test
    public void test_006() {
        System.out.println("[test004]----------------------"
                + "（A and B）or (C and D )--------------------------");
        PropertyFilter A = new PropertyFilter("userAddress",
                OperatorType.EQ, "吉林省");// "useAddress=山东省"
                                        // userAddress=:userAddress
        PropertyFilter B = new PropertyFilter("userName",
                OperatorType.EQ, "马跃");//  userName=:userName
        PropertyFilter C = new PropertyFilter("userTelephone",
                OperatorType.EQ, "111");//  userAddress=:userAddress
        PropertyFilter D = new PropertyFilter("userEmail",
                OperatorType.EQ, "wangnana@163.com");// 
                                                     // userName=:userName

        ArrayList<PropertyFilter> andList_A = new ArrayList<PropertyFilter>();
        ArrayList<PropertyFilter> andList_C = new ArrayList<PropertyFilter>();
        ArrayList<PropertyFilter> orList_A = new ArrayList<PropertyFilter>();
        
        andList_A.add(B);
        A.and(andList_A);
        
        andList_C.add(D);
        C.and(andList_C);
        
        orList_A.add(C);
        A.or(C);
        
         propertyFilters.add(A);
         
 
         //测试生成hql正确
         String actual = HibernateRepository.getNameHql2(A);
         String expected = "(_e.userAddress=:userAddress and (_e.userName=:userName) or _e.userTelephone=:userTelephone and (_e.userEmail=:userEmail))";
         System.out.println("test_002 expected hql==>" + expected);
         System.out.println("test_002 acturl hql==>" + actual);
//         Assert.assertEquals(expected, actual);
         //测试提取值正确
         Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
         printPramValues(paramValues);
         Assert.assertEquals(4, paramValues.size());
         
         
         //测试集成
         Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                 propertyFilters);
         
         Assert.assertEquals(2, resultPage.getTotalCount());
    }
    
    /*
     * 测试模式 （(A or B or C ) and (D or E)
     */
    @Test
    public void test_007() {
        System.out.println("[test007]----------------------"
                + "（(A or B or C ) and (D or E)--------------------------");
        PropertyFilter A = new PropertyFilter("userAddress",
                OperatorType.EQ, "吉林省");// "useAddress=山东省"
                                        // userAddress=:userAddress
        PropertyFilter B = new PropertyFilter("userAddress",
                OperatorType.EQ, "河北省");//  userName=:userName
        PropertyFilter C = new PropertyFilter("userAddress",
                OperatorType.EQ, "河南");//  userAddress=:userAddress
        PropertyFilter D = new PropertyFilter("userName",
                OperatorType.EQ, "张三");// 
                                                     // userName=:userName
        PropertyFilter E = new PropertyFilter("userEmail",
                OperatorType.EQ, "wangxinbing@163.com");// 
                                                     // userName=:userName

        
        //A or B or C
        ArrayList<PropertyFilter> orList_A = new ArrayList<PropertyFilter>();
        orList_A.add(B);
        orList_A.add(C);
        A.or(orList_A);
        
        //D or E
        ArrayList<PropertyFilter> orList_D = new ArrayList<PropertyFilter>();
        orList_D.add(E);
        D.or(orList_D);
        
        
        //A and D
        propertyFilters.add(A);
        propertyFilters.add(D);
        
        
 
//         //测试生成hql正确
//         String actual = HibernateRepository.getNameHql2(A);
//         String expected = "(userAddress=:userAddress and (userName=:userName)) or (userTelephone=:userTelephone and (userEmail=:userEmail))";
//         System.out.println("test_002 expected hql==>" + expected);
//         System.out.println("test_002 acturl hql==>" + actual);
//         Assert.assertEquals(expected, actual);
//         //测试提取值正确
//         Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
//         printPramValues(paramValues);
//         Assert.assertEquals(3, paramValues.size());
         
         //测试集成
         Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                 propertyFilters);
         List<UserInfo> results =resultPage.getResult();
         for (UserInfo userInfo : results) {
            System.out.println("userInfo:userName--"+ userInfo.getUserName()+ "--userAddress"+ userInfo.getUserAddress()+"---userEmail--"+ userInfo.getUserEmail());
        }
         Assert.assertEquals(2, resultPage.getTotalCount());
    }
    
    /*
     * 测试对and的支持 ,测试  or左右的表达式中参数相同的情况
     * 测试模式 （A and B）or (C and D )
     */
    @Test
    public void test_008() {
        System.out.println("[test008]----------------------"
                + "（A and B）or (C and D )--------------------------");
        PropertyFilter A = new PropertyFilter("userAddress",
                OperatorType.EQ, "吉林省");// "useAddress=山东省"
                                        // userAddress=:userAddress
        PropertyFilter B = new PropertyFilter("userName",
                OperatorType.EQ, "马跃");//  userName=:userName
        PropertyFilter C = new PropertyFilter("userAddress",
                OperatorType.EQ, "河南");//  userAddress=:userAddress
        PropertyFilter D = new PropertyFilter("userName",
                OperatorType.EQ, "张三");//  userName=:userName

        //A and B
        ArrayList<PropertyFilter> andList_A = new ArrayList<PropertyFilter>();
        andList_A.add(B);
        A.and(andList_A);
        
        //C and D
        ArrayList<PropertyFilter> andList_C = new ArrayList<PropertyFilter>();
        andList_C.add(D);
        C.and(andList_C);
        
        //A or C
        ArrayList<PropertyFilter> orList_A = new ArrayList<PropertyFilter>();
        orList_A.add(C);
        A.or(orList_A);
        
        
      
        propertyFilters.add(A);


        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        String expected = "(_e.userAddress=:userAddress and (_e.userName=:userName) or _e.userAddress=:userAddress_1 and (_e.userName=:userName_1))";
        System.out.println("test_002 expected hql==>" + expected);
        System.out.println("test_002 acturl hql==>" + actual);
//        Assert.assertEquals(expected, actual);
        //测试提取值正确
        Map<String ,Object> paramValues =  HibernateRepository.getNameHqlParam2(A);
        printPramValues(paramValues);
        Assert.assertEquals(4, paramValues.size());
        
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        
        Assert.assertEquals(2, resultPage.getTotalCount());

    }
    
    /*
     * 测试对and的支持 
     * 测试模式 （A and B）or (C and D ) or (e and f)
     * 
     * propertyFilter 构造说明: 1 构造A B C D E F  共6个PropertyFilter
     *                         2  设定A的 andFilter 为 B 或者进行‘and’ 操作
     *                         3 设定A的orFilter 为 C 和 E
     *                         4 设定 C 的andFilter 为 D， E的andFilter 为F 
     *                         
     */
    @Test
    public void testAnd_Or_C() {
        // 测试对and的支持
        
        Page<UserInfo> page = new Page<UserInfo>();
        page.setPageNo(1);
        page.setPageSize(10);

        ArrayList<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();

        PropertyFilter A = new PropertyFilter("userAddress",
                OperatorType.EQ, "吉林省");// "useAddress=山东省"
                                        // userAddress=:userAddress
        PropertyFilter B = new PropertyFilter("userName",
                OperatorType.EQ, "马跃");//  userName=:userName
        PropertyFilter C = new PropertyFilter("userAddress",
                OperatorType.EQ, "河南");//  userAddress=:userAddress
        PropertyFilter D = new PropertyFilter("userName",
                OperatorType.EQ, "张三");//  userName=:userName
        PropertyFilter E = new PropertyFilter("userName",
                OperatorType.EQ, "王新兵");//  userName=:userName
        PropertyFilter F = new PropertyFilter("userEmail",
                OperatorType.EQ, "wangxinbing@163.com");//  userEmail=:userEmail
        
        /*A and B*/
        ArrayList<PropertyFilter> andList_A = new ArrayList<PropertyFilter>();
        andList_A.add(B);
        A.and(andList_A);

        /*C and D*/
        ArrayList<PropertyFilter> andList_C = new ArrayList<PropertyFilter>();
        andList_C.add(D);
        C.and(andList_C); 
        
        /*E and F*/
        ArrayList<PropertyFilter> andList_E = new ArrayList<PropertyFilter>();
        andList_E.add(F);
        E.and(andList_E);
        
        /*A or C */
        ArrayList<PropertyFilter> orList_A = new ArrayList<PropertyFilter>();
        orList_A.add(C);
        A.or(orList_A);
         /* C or E*/
        ArrayList<PropertyFilter> orList_C = new ArrayList<PropertyFilter>();
        orList_C.add(E);
        C.or(orList_C);
        
        /*添加 A*/
        propertyFilters.add(A);

        // 测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
                propertyFilters);
        Assert.assertEquals(3, resultPage.getTotalCount());

    }
    @Test
    public void testPropertyFilterToHql(){
    	PropertyFilter A = new PropertyFilter("orgCode", OperatorType.LIKE, "UUId");
        PropertyFilter B = new PropertyFilter("orgName", OperatorType.EQ, "${childOrgList.orgName}");
        PropertyFilter C = new PropertyFilter("childOrgList.orgName", OperatorType.EQ, "${childOrgList.childOrgList.orgName}");
        
        PropertyFilter D = new PropertyFilter("orgCode", OperatorType.EQ, "Id1");
        PropertyFilter E = new PropertyFilter("orgCode", OperatorType.EQ, "Id2");
        
        C.setToCharFormat("yyyy-mm-dd");
      
        //B and C
        B = B.and(C);
        
        //A or B
        A = A.or(B).or(D).or(E);
        
        propertyFilters.add(A);
        
        String expected = "left join _e.childOrgList _e0 left join _e0.childOrgList _e1 where (_e.orgCode like :orgCode) or (_e.orgName=_e0.orgName and _e0.orgName=_e1.orgname)";
        
        //测试生成hql正确
        String actual = HibernateRepository.getNameHql2(A);
        System.out.println(actual);
        
        List<OrderCondition> ords = new ArrayList<OrderCondition>();
        ords.add(new OrderCondition("childOrgList.orgId",true));
        
        actual = HibernateRepository.changePropertyAndOrderToHqlByFlag(true, propertyFilters, ords);
        System.out.println(actual);
    }

   @Test 
    public void testInProperty(){
	   
	   List<Long> idList = new ArrayList<Long>();
	   idList.add(1L);
	   idList.add(2L);
	   idList.add(3L);
	   PropertyFilter A = new PropertyFilter("userInfoId",
               OperatorType.IN, idList);// "useAddress=山东省"
	   
	   propertyFilters.add(A);
	   
	   //测试集成
       Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
               propertyFilters);
       
       Assert.assertEquals(3, resultPage.getTotalCount());
    }
   
   @Test 
   public void test(){
	   String toBeAppending = "testt=:fdsfasdf and dfdfdf=:name";
	   
	   PropertyFilter A = new PropertyFilter();
	   PropertyFilter B = new PropertyFilter();
	   
	   Pattern p  = Pattern.compile("\\w+[:]\\w+");
       Matcher m = p.matcher(toBeAppending);
       
       int start = 0;
       int i = 0;
       while (m.find(start)){
    	   System.out.println(m.group(i));
    	   start = toBeAppending.indexOf(m.group(), start);
    	   i ++;
       }
       
   }
   
   @Test
   public void test_LIKE_property(){
	   PropertyFilter pf = new PropertyFilter("name",OperatorType.LIKE, "%_");
	   List<PropertyFilter> list=new ArrayList<PropertyFilter>();
       list.add(pf);
       String s = HibernateRepository.getHql2(pf);
       
	   Assert.assertEquals(HibernateRepository.getHql2(pf),"_e.name like ? escape '\\'");
	   Assert.assertEquals(HibernateRepository.getNameHql2(pf),"(_e.name like :name"+pf.hashCode()+" escape '\\')");
	   
	   Assert.assertEquals(HibernateRepository.getNameHqlParam(pf).get("name"+pf.hashCode()),"%\\%\\_%");
	   Assert.assertEquals(HibernateRepository.getHqlParam(pf)[0],"%\\%\\_%");
   }
   
   /*
    * 测试模式 （(A or B or C ) and (D or E)
    */
   @Test
   public void test_009() {
       System.out.println("[test007]----------------------"
               + "（(A or B or C ) and (D or E)--------------------------");
       PropertyFilter proper=new PropertyFilter("#hql"," userName='马跃'");
       List<PropertyFilter> list=new ArrayList<PropertyFilter>();
       list.add(proper);
        
        //测试集成
        Page<UserInfo> resultPage = userInfoDao.getPageByProperties(page,
        		list);
        List<UserInfo> results =resultPage.getResult();
        for (UserInfo userInfo : results) {
           System.out.println("userInfo:userName--"+ userInfo.getUserName()+ "--userAddress"+ userInfo.getUserAddress()+"---userEmail--"+ userInfo.getUserEmail());
       }
//        Assert.assertEquals(2, resultPage.getTotalCount());
   }
}
